// JavaScript Document

// JS控制图片显示的大小（图片等比例缩放）
function AutoImage(maxWidth, maxHeight, objImg) {
    var img = new Image(); //新建一个图片对象
    img.src = objImg.src; //获取图片地址
    var hRatio; //未定义图片比例宽变量
    var wRatio; //未定义图片比例长变量
    var Ratio = 1; //比例为实际大小
    var w = img.width; //图片长度
    var h = img.height; //图片宽度
    wRatio = maxWidth / w; //获取长比例
    hRatio = maxHeight / h; //获取宽比例
    if (maxWidth == 0 && maxHeight == 0) { //当值为0时原图显视
        Ratio = 1;
    } else if (maxWidth == 0) { //当高度比例小于原图时按比例高度显视
        if (hRatio < 1) Ratio = hRatio;
    } else if (maxHeight == 0) { //当宽度比例小于原图时按比例宽度显视
        if (wRatio < 1) Ratio = wRatio;
    } else if (wRatio < 1 || hRatio < 1) {
        Ratio = (wRatio <= hRatio ? wRatio: hRatio);
    }
    if (Ratio < 1) {
        w = w * Ratio;
        h = h * Ratio;
    }
    objImg.height = h;
    objImg.width = w;
}
window.onload=function() {

// 幻灯片
$(function(){
$("#focus").hover(function(){$("#focus-prev,#focus-next").show();},function(){$("#focus-prev,#focus-next").hide();});
$("#focus").slide({ 
mainCell:"#focus-bar-box ul",
targetCell:"#focus-title a",
titCell:"#focus-num a",
prevCell:"#focus-prev",
nextCell:"#focus-next",
effect:"left",
easing:"easeInOutCirc",
autoPlay:true,
delayTime:200
})
});

// 浮动
$(document).ready(function(e) {			
	t = $('.fixed').offset().top; //导航距离屏幕顶部距离
	mh = $('.main').height();     
	fh = $('.fixed').height();
	$(window).scroll(function(e){
		s = $(document).scrollTop();	
		if(s > t - 10){
			$('.fixed').css('position','fixed');
			if(s + fh > mh){
				$('.fixed').css('top',mh-s-fh+'px');	
			}				
		}else{
			$('.fixed').css('position','');
		}
	})
});

}